package com.wei;

/**
 * ThreadGroupTest
 *
 * @author :sunwei
 * @description:
 * @date create in 23:27  2021/6/17
 */
public class ThreadGroupAccessTest {
    
    public static void main(String[] args) {
        ThreadGroup tg1 = new ThreadGroup("TG1");
        new Thread(tg1, () -> {
            System.out.println(Thread.currentThread().getName() + "'s threadGroup is " + Thread.currentThread().getThreadGroup().getName());
            System.out.println(Thread.currentThread().getThreadGroup().getName() + "'s parent is " + Thread.currentThread().getThreadGroup().getParent().getName());
    
        }, "T1").start();
        
        ThreadGroup tg2 = new ThreadGroup("TG2");
        
        new Thread(tg2, () -> {
            System.out.println(Thread.currentThread().getName() + " 's threadGroup is " + Thread.currentThread().getThreadGroup().getName());
            System.out.println(Thread.currentThread().getThreadGroup().getName() + "'s parent is " + Thread.currentThread().getThreadGroup().getParent().getName());
            
        }, "T2").start();
    }
    
}
